{% extends "base.html" %}

{% block title %}编辑消费记录{% endblock %}

{% block content %}
<div class="container mt-5 form-container">
    <h1 class="mb-4">编辑消费记录</h1>

    <form action="" method="post">
        <div class="mb-3">
            <label for="description" class="form-label">消费内容:</label>
            <input type="text" name="description" class="form-control" value="{{ expense.description }}" required>
        </div>

        <div class="mb-3">
            <label for="amount" class="form-label">金额:</label>
            <input type="number" step="0.01" name="amount" class="form-control" value="{{ expense.amount }}" required>
        </div>

        <div class="mb-3">
            <label for="payment_method" class="form-label">支付方式:</label>
            <input type="text" name="payment_method" class="form-control" value="{{ expense.payment_method }}" required>
        </div>

        <div class="mb-3">
            <label for="category" class="form-label">类别:</label>
            <select name="category" class="form-select" required>
                {% for category in categories %}
                <option value="{{ category.id }}" {% if category.id == expense.category_id %}selected{% endif %}>
                    {{ category.name }}
                </option>
                {% endfor %}
            </select>
        </div>

        <button type="submit" class="btn btn-success">保存修改</button>
    </form>

    <a href="{{ url_for('view_expenses') }}" class="btn btn-secondary mt-3">返回上页</a>
</div>
{% endblock %}
